#ifndef _GUIPARAMMANAGERPANEL_H_INCLUDE_
#define _GUIPARAMMANAGERPANEL_H_INCLUDE_

#include "common.h"
#include <wx/dataview.h>
#include "gui/guimanager.h"
#include "signal.hpp"

class GuiParamManagerPanel;

class GuiNodeParamEditPanel : public wxPanel
{
public:
    GuiNodeParamEditPanel(wxWindow* parent);
    ~GuiNodeParamEditPanel();

    // 设置当前编辑区段
    inline void setGuiBaseNode(GuiBaseNode *pGuiBaseNode)
    {
        mGuiBaseNode=pGuiBaseNode;
    }
    // 得到当前编辑区段
    inline const GuiBaseNode* getSectNode(void) { return mGuiBaseNode; }
    // 挂接道岔改变信号槽
    void sig_ProcessItemChanged(GuiParamManagerPanel *pGuiParamManagerPanel);
    // 获取所有参数数据
    std::map<wxString, wxString> GetData() const;
    // 设置参数数据
    void SetData(const std::map<wxString, wxString>& data);
    // 重置所有参数
    void resetAllData(void);

private:
    void InitUI();

    void OnNodeTypeComboBoxSelected(wxCommandEvent& event);

    void OnIDTextChanged(wxCommandEvent& event);
    void OnIDTextKillFocus(wxFocusEvent& event);
    void OnIDTextEnter(wxCommandEvent& event);

    void OnNameTextChanged(wxCommandEvent& event);
    void OnNameTextKillFocus(wxFocusEvent& event);
    void OnNameTextEnter(wxCommandEvent& event);

    void OnTipTextChanged(wxCommandEvent& event);
    void OnTipTextKillFocus(wxFocusEvent& event);
    void OnTipTextEnter(wxCommandEvent& event);

    void OnRectTextChanged(wxCommandEvent& event);
    void OnRectTextKillFocus(wxFocusEvent& event);
    void OnRectTextEnter(wxCommandEvent& event);

    void OnNormalColorTextChanged(wxCommandEvent& event);
    void OnNormalColorTextKillFocus(wxFocusEvent& event);
    void OnNormalColorTextEnter(wxCommandEvent& event);

    void OnOverColorTextChanged(wxCommandEvent& event);
    void OnOverColorTextKillFocus(wxFocusEvent& event);
    void OnOverColorTextEnter(wxCommandEvent& event);

    void OnClickColorTextChanged(wxCommandEvent& event);
    void OnClickColorTextKillFocus(wxFocusEvent& event);
    void OnClickColorTextEnter(wxCommandEvent& event);

    void OnBorderColorTextChanged(wxCommandEvent& event);
    void OnBorderColorTextKillFocus(wxFocusEvent& event);
    void OnBorderColorTextEnter(wxCommandEvent& event);

    void OnNormalColorTextMouseEvent(wxMouseEvent& event);
    void OnOverColorTextMouseEvent(wxMouseEvent& event);
    void OnClickColorTextMouseEvent(wxMouseEvent& event);
    void OnBorderColorTextMouseEvent(wxMouseEvent& event);

private:
    GuiBaseNode *mGuiBaseNode;
    sigslot::signal4<GuiBaseNode*,int,wxString,wxString> sig_item_change;
    std::map<wxString, wxString> m_lastChangedData;

    wxStaticText* m_nodetypeLabel;
    wxComboBox* m_nodetypeText;
    bool m_nodetypeEditFinished;

    wxStaticText* m_IDLabel;
    wxTextCtrl* m_IDText;
    bool m_IDEditFinished;

    wxStaticText* m_NameLabel;
    wxTextCtrl* m_NameText;
    bool m_NameEditFinished;

    wxStaticText* m_TipLabel;
    wxTextCtrl* m_TipText;
    bool m_TipFinished;

    wxStaticText* m_RectLabel;
    wxTextCtrl* m_RectText;
    bool m_RectFinished;

    wxStaticText* m_NormalColorLabel;
    wxTextCtrl* m_NormalColorText;
    bool m_NormalColorFinished;

    wxStaticText* m_OverColorLabel;
    wxTextCtrl* m_OverColorText;
    bool m_OverColorFinished;

    wxStaticText* m_ClickColorLabel;
    wxTextCtrl* m_ClickColorText;
    bool m_ClickColorFinished;

    wxStaticText* m_BorderColorLabel;
    wxTextCtrl* m_BorderColorText;
    bool m_BorderColorFinished;
};

class GuiParamManagerPanel : public sigslot::has_slots<>,
                             public wxPanel
{
public:
    GuiParamManagerPanel(wxWindow *parent);
    ~GuiParamManagerPanel();

    void addGuiBaseNode(GuiBaseNode *pGuiBaseNode);
    void addData(const wxVector<wxVariant> data);

    void slot_ProcessItemChanged(GuiBaseNode *pGuiNode,int itemindex,wxString olddata,wxString newdata);

private:
    void OnSelectionChanged(wxDataViewEvent& event);
    void OnRightClick(wxDataViewEvent& event);

    void OnDeleteGuiNode(wxCommandEvent& event);
    void OnAddNewGuiNode(wxCommandEvent& event);

private:
    wxDataViewCtrl* m_dvc;
    wxDataViewListStore* m_store;

    GuiNodeParamEditPanel *m_GuiNodeParamEditPanel;
};

#endif // GUIPARAMMANAGERPANEL_H
